﻿<aside class="release-aside" tag="" onclick="AddToFavorites(this)">点击收藏</aside>
<script>

    var projectID;

    function AfterAddToFavorites(ctx) {
        if (ctx == null) {
            common.alertMessage("无数据.");
            return;
        }

        $(".release-aside").html("已收藏");
    }

    function AddToFavorites(obj) {

        var id = $(obj).attr("tag");
        if (!common.checkValue(id))
            return;

        var values = {};

        values.ProjectID = id;

        common.commonAjax({ type: 'Post', url: '/api/project/AddToFavorites', data: values, sMethod: AfterAddToFavorites });
    }

    function AfterCheckFavorites(ctx) {
        if (ctx == null || ctx.ResponseStr == "False") {
            $(".release-aside").attr("tag", projectID);
            return;
        }

        $(".release-aside").html("已收藏");
    }

    function Init(id) {
        projectID = id;
        common.commonAjax({ type: 'Get', url: '/api/project/CheckFavorites?id=' + id, sMethod: AfterCheckFavorites });
    }

</script>